package leetcode;

public class twentythird {
    public static int findMin(int[] nums) {
        int n=nums.length-1;
        if(nums.length==1){
            return nums[0];
        }
        int left=0;
        int right=n;
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]>nums[n]){
                left=mid+1;
            }
            if(nums[mid]<=nums[n]){
                right=mid;
            }
        }
        return nums[left];

    }

    public static void main(String[] args) {
        int[] nums={3,4,5,1,2};
        int min = findMin(nums);
        System.out.println(min);

    }
}
